/**
 * 控制操作区是否显示
 * @param psColumn 操作列显示总控
 * @param... psButtonXXX 单个按钮是否有权限码
 * @PS:如果放至列内会多次调用权限码校验方法
 */
var psOptControl ={
    psColumn:dealPermission(['role_edit','role_remove']),
    psButtonEdit:(dealPermission(['role_edit']) ? 'none' : 'bolck'),
    psButtonDelete:(dealPermission(['role_remove']) ? 'none' : 'bolck')
};
var cmsOrgType;
//页面加载
$(function() {
    var columns = [[{field: 'id', title: '', hidden: true},
        //      {field: 'deal', title: '操作', align:'center',width: 120,formatter:lookExamineSkip},
        //          formatter: function(value,rec,index){
        //              if(value){
        //                  return value;
        //              }
        //              var str = '';
        //              if((rec.status == -1) && ($("#loginUserCode").val() == rec.createEmp)){
        //                  str = '<a class="icon-line iconfont uce-edit" title="编辑" onclick="openEdit(\''+rec.idStr+'\', \''+ rec.code +'\',1)" href="javascript:void(0)"></a>';
        //                  str = str + '<a class="icon-line iconfont uce-delete" title="删除" onclick="deleteCsWoCustSer(\''+index+ '\')") href="javascript:void(0)"></a>';
        //              }else{
        //                  str = '<a class="tree-icon tree-file" title="查看"  onclick="openCheck(\''+rec.idStr+'\', \''+ rec.code +'\', \''+ rec.source +'\',3)" href="javascript:void(0)"></a>';
        //                  // if((rec.orderTypeStr == '1099949533046892452') || (rec.orderTypeStr == '1099949533046892454') ){
        //                  if(rec.woLabel == 0){
        //                      str = str + '<a class="icon-line iconfont uce-see-details" title="流程追踪"  onclick="HgUtil.processTraceView(\''+rec.processinstId+'\')" href="javascript:void(0)"></a>';
        //                  }
        //              }
        //              return str;
        //          }
        //      },
        {field: 'codeName', title: '组织名称', align: 'center',width : 150,formatter:lookExamineSkip},
        {field: 'orderSum', title: '工单总数', align: 'center',width : 100,formatter:orderSum},
        {field: 'untreatedOrder',title : '未处理工单数',align:'center',width : 150,formatter:untreatedOrder},
        {field: 'unverifyOrder', title: '未核实工单数', align: 'center',width : 150,formatter:unverifyOrder},
        {field: 'undutyOrder', title: '未定责工单数', align: 'center', width: 100,formatter:undutyOrder},
        {field: 'treatedOrder', title: '已处理工单数', align: 'center',width : 150,formatter:treatedOrder},
        {field: 'verifyOrder', title: '已核实工单数', align: 'center',width : 150,formatter:verifyOrder},
        {field: 'dutyOrder', title: '已定责工单数', align: 'center',width : 150,formatter:dutyOrder},
        {field: 'urgeOrder', title: '催办工单数', align: 'center',width : 150,formatter:urgeOrder},
        {field: 'upgradesOrder', title: '升级工单数', align: 'center',width : 150,formatter:upgradesOrder}
        //     {field: 'Ranking', title: '排名',width : 200,align: 'center'}
    ]];
    /** 加载表格 */
    newloadGrid('dgProblemOrder', columns, {
        url : '',
        pageSize : 20,
        toolbar : '#tlbProblemOrder',
        fitColumns : true,
        fit : false,
        singleSelect : false,
        onLoadSuccess : function(data) {
            $(".tip").tooltip({
                onShow : function() {
                    $(this).tooltip('tip').css({
                        width : '300',
                        boxShadow : '1px 1px 3px #292929'
                    });
                }
            });
        }
    });
//          newloadGrid('dgSecondary', columns, {
//              url : '',
//              pageSize : 50,
//              toolbar : '#dlgSecondary',
//              fitColumns : true,
//              fit : false,
//              singleSelect : false,
//              onLoadSuccess : function(data) {
//                  $(".tip").tooltip({
//                      onShow : function() {
//                          $(this).tooltip('tip').css({
//                              width : '300',
//                              boxShadow : '1px 1px 3px #292929'
//                          });
//                      }
//                  });
//              }
//          });
    //加载 机构类型下拉框
    $('#orgType').uceCombobox({
        width: 150,
        editable: false,
        data: [{'value':'10','text':'省区'},
            {'value':'20','text':'财务中心'},
            {'value':'30','text':'网点'}]
    });
    //加载 机构类型下拉框
//    $('#orgTypeD').uceCombobox({
//        width: 100,
//        editable: false,
//        data: [{'value':'10','text':'省区'},
//            {'value':'20','text':'财务中心'},
//            {'value':'30','text':'网点'}]
//    });
    $('#timeType').uceCombobox({
        width: 150,
        editable: false,
        data: [{'value':'1','text':'自定义时间'},
            {'value':'2','text':'本月'},
            {'value':'3','text':'上月'}]

    });
    //$('#startTime').datetimebox({ readonly: true });
    //$('#endTime').datetimebox({ readonly: true });
    queryOrgType();
    initQueryBeginTime(true);
    initQueryEndTime();
});

//初始化查询的开始时间
function initQueryBeginTime(value){
    var date = new Date();
    var year = date.getFullYear();
    var month = date.getMonth() + 1;
    var date = date.getDate();
    var beginTime = year + "-" + month +"-"+ date +" 00:00:00";
    var begin = Date.parse(beginTime);

    $("#startTime").datetimebox('setValue',beginTime);
    $("#startTimeD").datetimebox('setValue',beginTime);

    if(value == true){
        $('#timeType').combobox('setValue','1');
    }
//    $('#startTime').datebox('setValue', beginTime);
//    $('#startTimeD').datebox('setValue', beginTime);
//    $('#timeType').combobox('setValue','1');
//    $("#startTime").attr("readonly", "readonly");
//    $("#endTime").attr("readonly", "readonly");


    //return formatTime(new Date(begin));
}
// 初始化查询的结束时间
function initQueryEndTime(){
    var date = new Date();
    var year = date.getFullYear();
    var month = date.getMonth() + 1;
    var date = date.getDate();
    var endTime = year + "-" + month +"-"+ date + " 23:59:59" ;
//    var end = Date.parse(endTime);
    $("#endTime").datetimebox('setValue',formatTime(new Date(endTime)));
    $("#endTimeD").datetimebox('setValue',formatTime(new Date(endTime)));

//     $('#endTime').datebox('setValue', endTime);
//     $('#endTimeD').datebox('setValue', endTime);
    //return formatTime(new Date(end));
}

function timeShow(value){
    if(value.value == '1'){
        $('#startTime').datetimebox({ readonly: false });
        $('#endTime').datetimebox({ readonly: false });
        initQueryBeginTime(false);
        initQueryEndTime();
    }else{
        $('#startTime').datetimebox({ readonly: true });
        $('#endTime').datetimebox({ readonly: true });
    }
}

var parentId = 0;
var childValue= '';

//导出
function doExport() {
    var arr = $('#dgProblemOrder').datagrid('getData');
    if (arr.total == 0) {
        showInfoMsg('没有查询到数据，无法导出！');
        return;
    }
    var type = $("#orgType").val();
    if(type == null || type == ''){
    	showInfoMsg('请选择机构类型，无法导出！');
        return;
    }
    var beginTime = $('#startTime').datetimebox('getValue');
    var endTime = $('#endTime').datetimebox('getValue');
    var timeType = $("#timeType").val();
    if(timeType == '1'){
        if(!$.trim(beginTime) || !$.trim(endTime)){
            showTips('开始时间和结束时间不能为空', 'error', 3000);
            return;
        }else{
            //得到开始时间和结束时间的月份
            var bt = new Date(beginTime);
            var et = new Date(endTime);
            if(bt>et){
                showTips('截止时间早于开始时间', 'error', 3000);
                return;
            }
            if(et.getTime() - bt.getTime() > 60*60*24*31*1000 ){
                showInfoMsg('查询时间不能超过31天！');
                return;
            }
            var nowTimeDate = new Date(Date.parse(beginTime));
            nowTimeDate.setHours(0, 0, 0, 0);
            var begin = Date.parse(nowTimeDate);
            $("#startTime").datetimebox('setValue',formatTime(new Date(begin)));
            var endTimeDate = new Date(Date.parse(endTime));
            endTimeDate.setHours(23, 59, 59, 0);
            var end = Date.parse(endTimeDate);
            $("#endTime").datetimebox('setValue',formatTime(new Date(end)));
        }
    }
	    $.messager.confirm("确认", "是否确认生成导出任务",
	    		function (r) {
			    	if (r) {
					    var data =serializeFormObj("formFindProblemOrder");
				        uceAjax(G_CTX_PATH + "/cs/csDisposeSurveyController/export.do", data, function (result) {
				            if (result.success == true) {
				            	openTabCrossDomainIcsSimple("exportFileController_forward","数据导出查看","/cs/exportFileController/forward.do",true,0,portal_global_systemCode,false);
				            }else if(result.success == false){
				                showInfoMsg(result.msg);
				                 return;
				            }
				        });
			    	}
	    });    
//    $("#formFindProblemOrder")
//        .form(
//            'submit',
//            {
//                url : G_CTX_PATH + '/cs/csDisposeSurveyController/export.do',
//                onSubmit : function() {
//                }
//            });
}

function queryOrgType(){
	$.ajax({
        // 请求方式
        type:"post",
        // 发送请求地址
        url:G_CTX_PATH + '/cs/csDisposeSurveyController/queryOrgType.do',
        // 设置返回数据的格式
        dataType:"json",
        // 请求成功后的回调函数 data为json格式
        success:function(data){
        	if (data.success == true) {
        		if(data.orgType == 30){
        			$('#orgType').combobox('readonly', true);
        		    $('#orgType').combobox('setValue','网点');
        		}
        		cmsOrgType = data.orgType;
        	}
        }
    });
}

//导出
function doExportD() {
    var arr = $('#dgSecondary').datagrid('getData');
    if (arr.total == 0) {
        showInfoMsg('没有查询到数据，无法导出！');
        return;
    }
	 $.messager.confirm("确认", "是否确认生成导出任务",
	    		function (r) {
			    	if (r) {
			    	    var type = $("#orgType").val();
			    	    if(type == null || type == ''){
			    	    	showInfoMsg('请先选择机构类型');
			    	        return;
			    	    }
			    	    var timeType = $("#timeType").val();
			    	    orgType = type;
			    	    if(type == '10'){
			    	        orgType = type;
			    	    }
			    	    if(type == '20'){
			    	        orgType = 30;
			    	    }
			    	    if(type == '财务中心'){
			    	    	orgType = 30;
			    	    }
			    	    if(type == '网点'){
			    	    	orgType = 30;
			    	    }
			    	    var orgCode = orgCode;
			    	    var timeType = $("#timeType").val();
			    	    var startTime = $('#startTime').datetimebox('getValue');
			    	    var endTime = $('#endTime').datetimebox('getValue');
			    	    var codeName = $('#codeNameD').textbox('getValue');
			    	    var queryType = $("#queryType").val();
			    	    var data = {'codeNameD':codeName,'startTimeD':startTime,'endTimeD':endTime,'orgTypeD':orgType,'queryType':queryType,'timeType':timeType};
//				        uceAjax(G_CTX_PATH + "/cs/csDisposeSurveyController/exportOrderDetail.do",{'codeNameD':codeName,'startTimeD':startTime,'endTimeD':endTime,'orgTypeD':orgType,'queryType':queryType,'timeType':timeType}, function (result) {
						var url=G_CTX_PATH + "/cs/csDisposeSurveyController/exportOrderDetail.do";//工单查询url
						uceAjax(url,data,function(result){
				            if (result.success == true) {
				            	openTabCrossDomainIcsSimple("exportFileController_forward","数据导出查看","/cs/exportFileController/forward.do",true,0,portal_global_systemCode,false);
				            }else if(result.success == false){
				                showInfoMsg(result.msg);
				                 return;
				            }
				        });
			    	}
	    });
}

//重置
function resetQueryD(){
    $("#formFindProblemOrderD").form('reset');
    var date = new Date();
    var year = date.getFullYear();
    var month = date.getMonth() + 1;
    var date = date.getDate();
//    var beginTime = year + "-" + month +"-"+ date ;
//    $('#startTime').datetimebox('setValue', beginTime);
    var beginTime = year + "-" + month +"-"+ date + " 00:00:00";
    var begin = Date.parse(beginTime);
    $("#startTimeD").datetimebox('setValue',formatTime(new Date(begin)));
    
    var date = new Date();
    var year = date.getFullYear();
    var month = date.getMonth() + 1;
    var date = date.getDate();
//    var endTime = year + "-" + month +"-"+ date ;
//    $('#endTime').datetimebox('setValue', endTime);
    var endTime = year + "-" + month +"-"+ date + " 23:59:59";
    var end = Date.parse(endTime);
    $("#endTimeD").datetimebox('setValue',formatTime(new Date(end)));
}

//查询
function findOrderDetail() {
    var orgType = $("#orgTypeD").val();
    if(orgType == null || orgType == ''){
        showInfoMsg("请选择机构类型");
        return;
    }
    if(cmsOrgType == 30){
        if(orgType == '10' || orgType == '20'){
            showInfoMsg("网点不能查询省区以及财务中心");
            return;
        }
    }
    var beginTime = $('#startTimeD').datetimebox('getValue');
    var endTime = $('#endTimeD').datetimebox('getValue');
    if(!$.trim(beginTime) || !$.trim(endTime)){
        showTips('开始时间和结束时间不能为空', 'error', 3000);
        return;
    }else{
        //得到开始时间和结束时间的月份
        var bt = new Date(beginTime);
        var et = new Date(endTime);
        if(bt>et){
            showTips('截止时间早于开始时间', 'error', 3000);
            return;
        }
        if(et.getTime() - bt.getTime() > 60*60*24*31*1000 ){
            showInfoMsg('查询时间不能超过31天！');
            return;
        }
        var nowTimeDate = new Date(Date.parse(beginTime));
        nowTimeDate.setHours(0, 0, 0, 0);
        var begin = Date.parse(nowTimeDate);
        $("#startTimeD").datetimebox('setValue',formatTime(new Date(begin)));
        var endTimeDate = new Date(Date.parse(endTime));
        endTimeDate.setHours(23, 59, 59, 0);
        var end = Date.parse(endTimeDate);
        $("#endTimeD").datetimebox('setValue',formatTime(new Date(end)));
    }
    var url=G_CTX_PATH + '/cs/csDisposeSurveyController/findOrderDetail.do';
    $('#dgSecondary').datagrid('options').url = url;
    $("#dgSecondary").datagrid("load", serializeFormObj("formFindProblemOrderD"));
}

//查询
function findOrderIndex(value) {
	getJobState("csWoCustOrderJob");
    var orgType = $("#orgType").val();
    if(orgType == null || orgType == ''){
        showInfoMsg("请选择机构类型");
        return;
    }
    console.log(decodeURI('${sessionScope.CURRENT_USER}'));
    if(cmsOrgType == 30){
        if(orgType == '10' || orgType == '20'){
            showInfoMsg("网点不能查询省区以及财务中心");
            return;
        }
    }
    var timeType = $("#timeType").val();
    if(timeType == null || timeType == ''){
        showTips('请选择时间类型', 'error', 3000);
        return;
    }
    var codeName = $.trim($("#codeName").textbox('getValue'));
    var beginTime = $('#startTime').datetimebox('getValue');
    var endTime = $('#endTime').datetimebox('getValue');
    var inputType = null;
    if(timeType == '1'){
        if(!$.trim(beginTime) || !$.trim(endTime)){
            showTips('开始时间和结束时间不能为空', 'error', 3000);
            return;
        }else{
            //得到开始时间和结束时间的月份
            var bt = new Date(beginTime);
            var et = new Date(endTime);
            if(bt>et){
                showTips('截止时间早于开始时间', 'error', 3000);
                return;
            }
            if(et.getTime() - bt.getTime() > 60*60*24*31*1000 ){
                showInfoMsg('查询时间不能超过31天！');
                return;
            }
            var nowTimeDate = new Date(Date.parse(beginTime));
            nowTimeDate.setHours(0, 0, 0, 0);
            var begin = Date.parse(nowTimeDate);
            $("#startTime").datetimebox('setValue',formatTime(new Date(begin)));
            var endTimeDate = new Date(Date.parse(endTime));
            endTimeDate.setHours(23, 59, 59, 0);
            var end = Date.parse(endTimeDate);
            $("#endTime").datetimebox('setValue',formatTime(new Date(end)));
        }
    }
    if(timeType == '4' && value == true){
        var productDataGridParams = {
            url: G_CTX_PATH + '/cs/csDisposeSurveyController/findOrderIndex.do',
            pageSize: 50,
            queryParams:{'orgType':orgType,'timeType':timeType,'codeName':codeName},
            // toolbar : '#dlgSecondary',
            toolbar : '#tlbProblemOrder',
            fitColumns : true,
            fit : false,
            singleSelect : false,
            onLoadSuccess : function(data) {
                $(".tip").tooltip({
                    onShow : function() {
                        $(this).tooltip('tip').css({
                            width : '300',
                            boxShadow : '1px 1px 3px #292929'
                        });
                    }
                });
            }
        };
        newloadGrid('dgProblemOrder', orderColumns, productDataGridParams);
    }else{
        if(value == true){
        	inputType = "0";
            var url=G_CTX_PATH + '/cs/csDisposeSurveyController/findOrderIndex.do';
        }else{
        	inputType = "1";
            var url=G_CTX_PATH + '/cs/csDisposeSurveyController/findOrgByName.do';
        }
        $('#inputType').val(inputType);
        $("#dgProblemOrder").datagrid("loadData",{"total":0,"rows":[]});
        $('#dgProblemOrder').datagrid('options').url = url;
        $("#dgProblemOrder").datagrid("load", serializeFormObj("formFindProblemOrder"));
    }
}

function getJobState(jobName){
	    uceAjax(G_CTX_PATH+"/cs/job/findJobState.do",{jobName:jobName},function (result) {
	        if(result.success == false){
	            showInfoTip(result.data, "", 2000);
	        }
	        if(result.data.isSuccess == 1){
	           $("#sjzt").find("span").find("span").text("数据状态: "+result.data.startTime+"~"+result.data.completeTime);
	            $("#sjzt").show();
	            $("#sjzt").removeClass("disposeWait")
	            $("#sjzt").addClass("disposeSuccess")
	        }else{
	            $("#sjzt").find("span").find("span").text("数据状态: "+result.data.startTime+"~");
	            $("#sjzt").show();
	            $("#sjzt").removeClass("disposeSuccess")
	            $("#sjzt").addClass("disposeWait")
	        }
	        console.log(JSON.stringify(result.data));
	
	    },"POST");
	 }

function formPartnerTypeType(value) {
    if (value == "10") {
        return "省区";
    }
    if (value == "20") {
        return "财务中心";
    }
    if (value == "30") {
        return "网点";
    }
    return "";
}

function confirmEnding(str, target) {

    if(str.endsWith(target)){
        return true;
    }
    return false;
}

function forIsRedeployType(value){
	if(value == null || value == ''){
		return "否";
	}
	if(value == '0'){
		return "否"
	}
	return "是";
}

function isOverType(value){
	if(value == 1){
		return "是";
	}
	return "否";
}

function forIsAuditType(value){
	if(value == 1 || value == 2){
		return "是";
	}
	return "否";
}

function auditResultType(value){
	if(value == 1){
		return "通过";
	}
	if(value == 2){
		return "不通过";
	}
	return null;
}

function dutyResultType(value){
	if(value == 1){
		return "成立";
	}
	if(value == 2){
		return "不成立";
	}
	return null;
}

function openLookOrder(orgCode,orgType,codeName,value){
    var orgTypeD = orgType;
    var type = $("#orgType").val();
    if(type == null || type == ''){
    	showInfoMsg('请先选择机构类型');
        return;
    }
    if(orgType == '20' || orgType == '10'){
        $('#orgType').combobox('setValue',formPartnerTypeType(orgType));
        if(type == '10'){
            orgType = type;
        }
//        $('#orgCode').textbox('setValue',orgCode);
        $('#codeName').textbox('setValue',value);
//        $("#inputType").val("1");
        $('#inputType').val("1");
        findOrderIndex(false);
    }
//    else{
//        openDialog("dlgSecondary", '订单查看');
//        //查询前先清空grid
//        $("#dgSecondary").datagrid("loadData",{"total":0,"rows":[]});
//        var orgCode = orgCode;
//        var timeType = $("#timeType").val();
//        var startTime = $('#startTime').datetimebox('getValue');
//        var endTime = $('#endTime').datetimebox('getValue');
//        var productDataGridParams = {
//            url: G_CTX_PATH + '/cs/csDisposeSurveyController/findOrderDetail.do',
//            pageSize: 50,
//            queryParams:{'branchesOrgCode':orgCode,'startTimeD':startTime,'endTimeD':endTime,'timeType':timeType,'queryType':0},
//            // toolbar : '#dlgSecondary',
//            pagePosition:'top',
//            rownumbers:'true',
//            singleSelect: 'true',
//            fitColumns: 'true',
//            collapsible : 'true',
//            pagination: 'true'
//        };
//        newloadGrid('dgSecondary', orderDetailColumns, productDataGridParams);
//        $('#orgTypeD').combobox('setValue',formPartnerTypeType(orgTypeD));
//        $('#codeNameD').textbox('setValue',codeName);
//        $('#startTimeD').datebox('setValue', startTime);
//        $('#endTimeD').datebox('setValue', endTime);
//        $("#queryType").val(queryType);
//    }
}

function openLookOrderDetail(orgCode,orgType,codeName,queryType){
    var type = $("#orgType").val();
    if(type == null || type == ''){
    	showInfoMsg('请先选择机构类型');
        return;
    }
    var timeType = $("#timeType").val();
    openDialog("dlgSecondary", '订单查看');
    //查询前先清空grid
    $("#dgSecondary").datagrid("loadData",{"total":0,"rows":[]});
    var orgTypeD = orgType;
    if(type == '10'){
        orgType = type;
    }
    var orgCode = orgCode;
    var timeType = $("#timeType").val();
    var startTime = $('#startTime').datetimebox('getValue');
    var endTime = $('#endTime').datetimebox('getValue');
    var productDataGridParams = {
        url: G_CTX_PATH + '/cs/csDisposeSurveyController/findOrderDetail.do',
        pageSize: 50,
        queryParams:{'codeNameD':codeName,'startTimeD':startTime,'endTimeD':endTime,'orgTypeD':orgType,'queryType':queryType,'timeType':timeType},
        // toolbar : '#dlgSecondary',
        pagePosition:'top',
        rownumbers:'true',
        singleSelect: 'true',
        fitColumns: 'true',
        collapsible : 'true',
        pagination: 'true'
    };
    newloadGrid('dgSecondary', orderDetailColumns, productDataGridParams);
    $('#orgTypeD').textbox('setValue',formPartnerTypeType(orgType));
    $('#timeTypeD').textbox('setValue',timeType);
    $('#codeNameD').textbox('setValue',codeName);
    $('#startTimeD').datetimebox('setValue', startTime);
    $('#endTimeD').datetimebox('setValue', endTime);
    $("#queryType").val(queryType);
}
function openDetail(orgCode){
    alert("111");
}
/**
 *
 * 		        {field: 'orderSum', title: '工单总数', align: 'center',width : 100,formatter:orderSum},
 {field: 'untreatedOrder',title : '未处理工单数',align:'center',width : 150,formatter:untreatedOrder},
 {field: 'unverifyOrder', title: '未核实工单数', align: 'center',width : 150,formatter:unverifyOrder},
 {field: 'undutyOrder', title: '未定责工单数', align: 'center', width: 100,formatter:undutyOrder},
 {field: 'treatedOrder', title: '已处理工单数', align: 'center',width : 150,formatter:treatedOrder},
 {field: 'verifyOrder', title: '已核实工单数', align: 'center',width : 150,formatter:verifyOrder},
 {field: 'dutyOrder', title: '已定责工单数', align: 'center',width : 150,formatter:dutyOrder},
 {field: 'urgeOrder', title: '催办工单数', align: 'center',width : 150,formatter:urgeOrder},
 {field: 'upgradesOrder', title: '升级工单数', align: 'center',width : 150,formatter:upgradesOrder}
 */

function lookExamineSkip(value,row,index,data){
    if(value == null){
        return null;
    }
    return '<a style="color: #0000FF;" onclick="openLookOrder(\''+row.orgCode+'\', \''+ row.orgType +'\', \''+ row.codeName +'\', \''+ value +'\')" href="javascript:void(0)">'+value+'</a>';
}

function untreatedOrder(value,row,index,data){
    if(value == null){
        return null;
    }
    return '<a style="color: #0000FF;" onclick="openLookOrderDetail(\''+row.orgCode+'\', \''+ row.orgType +'\', \''+ row.codeName +'\', \''+ 1 +'\')" href="javascript:void(0)">'+value+'</a>';
}
function unverifyOrder(value,row,index,data){
    if(value == null){
        return null;
    }
    return '<a style="color: #0000FF;" onclick="openLookOrderDetail(\''+row.orgCode+'\', \''+ row.orgType +'\', \''+ row.codeName +'\', \''+ 2 +'\')" href="javascript:void(0)">'+value+'</a>';
}
function undutyOrder(value,row,index,data){
    if(value == null){
        return null;
    }
    return '<a style="color: #0000FF;" onclick="openLookOrderDetail(\''+row.orgCode+'\', \''+ row.orgType +'\', \''+ row.codeName +'\', \''+ 3 +'\')" href="javascript:void(0)">'+value+'</a>';
}
function treatedOrder(value,row,index,data){
    if(value == null){
        return null;
    }
    return '<a style="color: #0000FF;" onclick="openLookOrderDetail(\''+row.orgCode+'\', \''+ row.orgType +'\', \''+ row.codeName +'\', \''+ 4 +'\')" href="javascript:void(0)">'+value+'</a>';
}
function verifyOrder(value,row,index,data){
    if(value == null){
        return null;
    }
    return '<a style="color: #0000FF;" onclick="openLookOrderDetail(\''+row.orgCode+'\', \''+ row.orgType +'\', \''+ row.codeName +'\', \''+ 5 +'\')" href="javascript:void(0)">'+value+'</a>';
}
function dutyOrder(value,row,index,data){
    if(value == null){
        return null;
    }
    return '<a style="color: #0000FF;" onclick="openLookOrderDetail(\''+row.orgCode+'\', \''+ row.orgType +'\', \''+ row.codeName +'\', \''+ 6 +'\')" href="javascript:void(0)">'+value+'</a>';
}
function urgeOrder(value,row,index,data){
    if(value == null){
        return null;
    }
    return '<a style="color: #0000FF;" onclick="openLookOrderDetail(\''+row.orgCode+'\', \''+ row.orgType +'\', \''+ row.codeName +'\', \''+ 7 +'\')" href="javascript:void(0)">'+value+'</a>';
}
function upgradesOrder(value,row,index,data){
    if(value == null){
        return null;
    }
    return '<a style="color: #0000FF;" onclick="openLookOrderDetail(\''+row.orgCode+'\', \''+ row.orgType +'\', \''+ row.codeName +'\', \''+ 8 +'\')" href="javascript:void(0)">'+value+'</a>';
}

function orderSum(value,row,index,data){
    if(value == null){
        return null;
    }
    return '<a style="color: #0000FF;" onclick="openLookOrderDetail(\''+row.orgCode+'\', \''+ row.orgType +'\', \''+ row.codeName +'\', \''+ 10 +'\')" href="javascript:void(0)">'+value+'</a>';
}
//重置
function resetQuery(){
    $("#formFindProblemOrder").form('reset');
    initQueryBeginTime();
    //初始化事件时间
    initQueryEndTime();
    $('#timeType').combobox('setValue','1');
    if(cmsOrgType == 30){
    	$('#orgType').combobox('setValue',formPartnerTypeType(cmsOrgType));
    	$('#orgType').textbox('readonly', true);
    }
}


var columns = [[{field: 'id', title: '', hidden: true},
    {field: 'codeName', title: '组织名称', align: 'center',width : 150,formatter:lookExamineSkip},
    {field: 'orderSum', title: '工单总数', align: 'center',width : 100,formatter:orderSum},
    {field: 'untreatedOrder',title : '未处理工单数',align:'center',width : 150,formatter:untreatedOrder},
    {field: 'unverifyOrder', title: '未核实工单数', align: 'center',width : 150,formatter:unverifyOrder},
    {field: 'undutyOrder', title: '未定责工单数', align: 'center', width: 100,formatter:undutyOrder},
    {field: 'treatedOrder', title: '已处理工单数', align: 'center',width : 150,formatter:treatedOrder},
    {field: 'verifyOrder', title: '已核实工单数', align: 'center',width : 150,formatter:verifyOrder},
    {field: 'dutyOrder', title: '已定责工单数', align: 'center',width : 150,formatter:dutyOrder},
    {field: 'urgeOrder', title: '催办工单数', align: 'center',width : 150,formatter:urgeOrder},
    {field: 'upgradesOrder', title: '升级工单数', align: 'center',width : 150,formatter:upgradesOrder}
]];

var orderColumns = [[{field: 'id', title: '', rowspan: 2, hidden: true},
    {field: 'codeName', title: '组织名称', align: 'center',rowspan: 2,width : 70,formatter:lookExamineSkip},
//    		        {field: 'orderSum', title: '工单总数', align: 'center',width : 100,formatter:orderSum},
//    		        {field: 'untreatedOrder',title : '未处理工单数',align:'center',width : 150,formatter:untreatedOrder},
//    		        {field: 'unverifyOrder', title: '未核实工单数', align: 'center',width : 150,formatter:unverifyOrder},
//    		        {field: 'undutyOrder', title: '未定责工单数', align: 'center', width: 100,formatter:undutyOrder},
//    		        {field: 'treatedOrder', title: '已处理工单数', align: 'center',width : 150,formatter:treatedOrder},
//    		        {field: 'verifyOrder', title: '已核实工单数', align: 'center',width : 150,formatter:verifyOrder},
//    		        {field: 'dutyOrder', title: '已定责工单数', align: 'center',width : 150,formatter:dutyOrder},
//    		        {field: 'urgeOrder', title: '催办工单数', align: 'center',width : 150,formatter:urgeOrder},
//    		        {field: 'upgradesOrder', title: '升级工单数', align: 'center',width : 150,formatter:upgradesOrder}
    {field: 'orderSum', title: '工单总数', align: 'center',rowspan: 2,width : 50,formatter:orderSum},
    {title: "本周", colspan: 8,width : 560 },
    {title: "上周", colspan: 8,width : 560 }],
    [{field: 'untreatedOrder',title : '未处理工单数',align:'center',rowspan: 1,width : 70,formatter:untreatedOrder},
        {field: 'unverifyOrder', title: '未核实工单数', align: 'center',rowspan: 1,width : 70,formatter:unverifyOrder},
        {field: 'undutyOrder', title: '未定责工单数', align: 'center', rowspan: 1,width: 70,formatter:undutyOrder},
        {field: 'treatedOrder', title: '已处理工单数', align: 'center',rowspan: 1,width : 70,formatter:treatedOrder},
        {field: 'verifyOrder', title: '已核实工单数', align: 'center',rowspan: 1,width : 70,formatter:verifyOrder},
        {field: 'dutyOrder', title: '已定责工单数', align: 'center',rowspan: 1,width : 70,formatter:dutyOrder},
        {field: 'urgeOrder', title: '催办工单数', align: 'center',rowspan: 1,width : 70,formatter:urgeOrder},
        {field: 'upgradesOrder', title: '升级工单数', align: 'center',rowspan: 1,width : 70,formatter:upgradesOrder},

        {field: 'lastUntreatedOrder',title : '上周未处理工单数',align:'center',rowspan: 1,width : 70,formatter:untreatedOrder},
        {field: 'lastUnverifyOrder', title: '上周未核实工单数', align: 'center',rowspan: 1,width : 70,formatter:unverifyOrder},
        {field: 'lastUndutyOrder', title: '上周未定责工单数', align: 'center', rowspan: 1,width: 70,formatter:undutyOrder},
        {field: 'lastTreatedOrder', title: '上周已处理工单数', align: 'center',rowspan: 1,width : 70,formatter:treatedOrder},
        {field: 'lastVerifyOrder', title: '上周已核实工单数', align: 'center',rowspan: 1,width : 70,formatter:verifyOrder},
        {field: 'lastDutyOrder', title: '上周已定责工单数', align: 'center',rowspan: 1,width : 70,formatter:dutyOrder},
        {field: 'lastUrgeOrder', title: '上周催办工单数', align: 'center',rowspan: 1,width : 70,formatter:urgeOrder},
        {field: 'lastUpgradesOrder', title: '上周升级工单数', align: 'center',rowspan: 1,width : 70,formatter:upgradesOrder}
    ]];

var orderDetailColumns = [[{field: 'id', title: '', hidden: true},
//           		      	{field: 'deal', title: '操作', align:'center',width: 120,formatter:lookExamineSkip},
                        	{field: 'woCode', title: '工单编码', align: 'center',width : 150},
                        	{field: 'priority', title: '优先级', align: 'center',width : 150},
                        	{field: 'urgeNum', title: '催办次数', align: 'center', width: 150},
                        	{field: 'callNum', title: '来电次数',width : 150,align: 'center'},
                        	{field: 'waybillNum', title: '运单号', align: 'center',width : 150},
                        	{field: 'selDutyOrgName',title : '第一处理机构',align:'center',width : 150},
                        	{field: 'cmsFinanceCenterCode',title : '第一处理机构所属财务中心',align:'center',width : 150},
                        	{field: 'source',title : '工单来源',align:'center',width : 150},
                        	{field: 'sendOrgCode', title: '寄件网点', align: 'center',width : 150},
                        	{field: 'customerIdentity', title: '客户身份', align: 'center', width: 150},
                        	{field: 'custName', title: '客户名称', align: 'center',width : 150},
                        	{field: 'orderTypeName',title : '工单类型',align:'center',width : 150},
                        	{field: 'orderChilTypeName', title: '工单子类型', align: 'center',width : 150},
                        	{field: 'orderRemark', title: '问题描述', align: 'center',width : 150},
                        	{field: 'status',title : '状态',align:'center',width : 150},
                        	{field: 'submitter', title: '工单发起人', align: 'center', width: 150},
                        	{field: 'createTime',title : '创建时间',align:'center',width : 150,formatter:formatTime},
                        	{field: 'createOrg',title : '创建部门',align:'center',width : 150},
                        	{field: 'responseTime',title : '响应时间',align:'center',width : 150,formatter:formatTime},
                        	{field: 'responseOrg',title : '响应部门',align:'center',width : 150},
                        	{field: 'isRedeploy',title : '是否转派',align:'center',width : 150,formatter:forIsRedeployType},
                        	{field: 'isTimeout',title : '是否超时',align:'center',width : 150,formatter:isOverType},
                        	{field: 'overtime',title : '超时时间点',align:'center',width : 150,formatter:formatTime},
                        	{field: 'overtimeOrg',title : '超时处理机构',align:'center',width : 150},
                        	{field: 'overtimeEmp',title : '超时处理人',align:'center',width : 150},
                        	{field: 'submitTime',title : '处理提交时间',align:'center',width : 150,formatter:formatTime},
                        	{field: 'disposeOrg',title : '处理部门',align:'center',width : 150},
                        	{field: 'disposeEmp',title : '处理人',align:'center',width : 150},
                        	{field: 'disposeOrgFinanceCenterCode',title : '处理部门所属财务中心',align:'center',width : 150},
                        	{field: 'submitResult',title : '提交内容',align:'center',width : 150},
                        	{field: 'isNeedAudit',title : '是否需要审核',align:'center',width : 150,formatter:forIsAuditType},
                        	{field: 'auditResult',title : '审核结果',align:'center',width : 150,formatter:auditResultType},
                        	{field: 'auditSum',title : '审核不通过次数',align:'center',width : 150},
                        	{field: 'auditTime',title : '审核提交时间',align:'center',width : 150,formatter:formatTime},
                        	{field: 'auditOrg',title : '审核部门',align:'center',width : 150},
                        	{field: 'auditEmp',title : '审核人',align:'center',width : 150},
                        	{field: 'auditOrgFinanceCenterCode',title : '审核所属财务中心',align:'center',width : 150},
                        	{field: 'dutyTime',title : '定责提交时间',align:'center',width : 150,formatter:formatTime},
                        	{field: 'dutyOrg',title : '定责部门',align:'center',width : 150},
                        	{field: 'dutyResult',title : '定责结果',align:'center',width : 150,formatter:dutyResultType},
                        	{field: 'dutyEmp',title : '定责人',align:'center',width : 150},
                        	{field: 'firstTypeName',title : '定责一级类型',align:'center',width : 150},
                        	{field: 'secondeTypeName',title : '定责二级类型',align:'center',width : 150},
                        	{field: 'dutyName', title: '责任方名称', align: 'center',width : 150},
                        	{field: 'dutyOrgName', title: '责任机构名称', align: 'center', width: 150},
                        	{field: 'dutyOrgFinanceCenterCode', title: '责任机构所属财务中心',width : 150,align: 'center'},
                        	{field: 'personLiableName', title: '责任人', align: 'center', width: 150},
                        	{field: 'penalties', title: '罚款金额',width : 150,align: 'center'}
]];




